package com.neusoft.a312cxy.android18cxy.activity;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.widget.TextView;

import com.neusoft.a312cxy.android18cxy.R;
import com.neusoft.a312cxy.android18cxy.adapter.GuanzhuAdapter;
import com.neusoft.a312cxy.android18cxy.bean.MyguanzhuBean;
import com.neusoft.a312cxy.android18cxy.model.MySelfModel;

import java.util.List;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

/**
 * Created by Young on 2017/11/10.
 */

public class GuanzhuActivity extends AppCompatActivity {
    private TextView name,insert_time;
    private String userid;
    private RecyclerView recyclerView;
    private List mDatelist;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activiyty_guanzhu);
        initView();
        saveDate();
        getguanzhu();
        // getClubCourse();
    }
    public void initView(){
        name=(TextView)findViewById(R.id.name);
        insert_time=(TextView)findViewById(R.id.insert_time);
        recyclerView=(RecyclerView)findViewById(R.id.abcc);
        recyclerView.setLayoutManager(new LinearLayoutManager(GuanzhuActivity.this));
        recyclerView.setItemAnimator(new DefaultItemAnimator());
    }
    public void saveDate(){
        Intent intent = getIntent();
        Bundle bundle = intent.getExtras();
        //  shaitu_id = bundle.getString("shaitu_id");
        userid = bundle.getString("userid");

    }

    public void getguanzhu() {

        MySelfModel mySelfModel = new MySelfModel();
        Call<List<MyguanzhuBean>> call = mySelfModel.getmyguanzhu(/*userid*/"19");
        call.enqueue(new Callback<List<MyguanzhuBean>>() {
            @Override
            public void onResponse(Call<List<MyguanzhuBean>> call, Response<List<MyguanzhuBean>> response) {
                mDatelist=response.body();

                GuanzhuAdapter adapter= new GuanzhuAdapter(GuanzhuActivity.this,mDatelist);
                recyclerView.setAdapter(adapter);

            }

            @Override
            public void onFailure(Call<List<MyguanzhuBean>> call, Throwable t) {

                //  System.out.println("8");
            }
        });
    }
}
